package com.orangelife.mobile.web;

import com.common.sp.CommSp2;
import com.common.sp.UserSp;
import com.curry.android.util.StringUtil;
import com.orangelife.mobile.constants.WebViewURL;
import com.orangelife.mobile.util.LogE;

/**
 * <p/>
 * Created by 吴格非 on 2016-8-24.
 * <p/>
 *
 * @author 吴格非
 * @since v1.0.0
 */
public class PathUtil {
    /** 特殊URL的特殊处理 */
    public static String handlePath(String path) {
        if (!StringUtil.isBlank(path)) {
            if (path.contains(WebViewURL.COMMUNITY_ACTIVITY_FUNCTION)) {
                return getCommActivityPath(path);
            }
        }
        LogE.E(PathUtil.class.getSimpleName(), "after handle" + path);
        return path;
    }

    /** 处理社区活动路径 */
    private static String getCommActivityPath(String path) {
        if (path.contains("?")) {
            path = path + "&commid=" + CommSp2.getCommID() + "&accessToken=" + UserSp.getAccessToken();
        } else {
            path = path + "?commid=" + CommSp2.getCommID() + "&accessToken=" + UserSp.getAccessToken();
        }
        return path;
    }
}
